$(document).ready(function(){
    var E = window.wangEditor
    var editor = new E('#editor')
    // 或者 var editor = new E( document.getElementById('editor') )
    editor.create()
    var arr=window.location.href.split("?");
    var id=arr[1];
    var title='';
    var text='';
    $.get("/artmanage/findbyid",{id:id},function (data) {
         text =editor.txt.html(data.text);
         title=$("#title").val(data.title);
    })


    $("#btn2").click(function () {
        var date=new Date();
        text =editor.txt.html();
        title=$("#title").val();
        if(title==null||title==''||title.match(/^[ ]*$/)){
            alert("请填写标题")
        }else {
            $.post("/artmanage/update",{"title":title,"date":date,"text":text,"id":id},function (data) {
                if(data){
                    confirm("提交成功")
                    window.location.href="index.html";
                }
            })
        }

    })


})